<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class AreaResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {

        return [
            'AreaId' => $this->AreaId,
            'Fid' => $this->Fid,
            'AreaName' => $this->AreaName,
            'Co_ID' => $this->Co_ID,
            'lnglat' => $this->lnglat,
            "parentAreaName"=>new AreaResource($this->whenLoaded('parentAreaName'))
        ];
    }
}
